<template>
    <div>
<!--        <Spin fix v-if="isSpin">-->
<!--            <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>-->
<!--            &lt;!&ndash;<div>正在生成企业安全总监推荐表，请稍后</div>&ndash;&gt;-->
<!--            <div>下载中，请稍后</div>-->
<!--        </Spin>-->
        <Form :label-width="120" ref="formInline" :model="formInline">
            <div v-if="switchFlag">
                <Row :gutter="16" class="query-form2">
                    <i-col span="8">
                      <FormItem label="二级集团：" prop="twolevelOrgName">
                        <two-level-org org-code v-model="formInline.twolevelOrgName" ></two-level-org>
                      </FormItem>
                    </i-col>
                    <i-col span="8">
                      <FormItem label="所属公司：">
                        <company-select v-model="formInline.companyName"></company-select>
                      </FormItem>
                    </i-col>
                    <i-col span="8">
                        <FormItem label="所属部门：" prop="userName">
                            <Input v-model="formInline.orgName" placeholder="请填写所属部门"/>
                        </FormItem>
                    </i-col>
                </Row>
                <Row :gutter="16" class="query-form2" >
                    <i-col span="8">
                      <FormItem label="观察人员：">
                        <Input v-model="formInline.observationUserName" placeholder="请填写观察人员"/>
                      </FormItem>
                    </i-col>
                    <i-col span="8">
                      <FormItem label="观察时间：" prop="userName">
                        <DatePicker v-model="formInline.se_date" type="datetimerange" style="width: 100%" format="yyyy-MM-dd" placeholder="请选择观察时间（开始，结束）"></DatePicker>
                      </FormItem>
                    </i-col>
                    <i-col span="8">
                        <div style="float: right;">
                            <Button class="ivu-btn-query"  icon="md-search"  @click="query">查询</Button>
                            <Button class="ivu-btn-reset" style="margin-left: 10px" @click="cancel">重置</Button>
                            <Button @click="switchQuery(false)" style="margin-left: 10px" class="ivu-btn-switch2" type="text" >收起<Icon type="ios-arrow-up" /></Button>
                        </div>
                    </i-col>
                </Row>
            </div>
            <div v-else>
                <Row :gutter="16" class="query-form2" >
                    <i-col span="8">
                      <FormItem label="二级集团：" prop="twolevelOrgName">
                        <two-level-org org-code v-model="formInline.twolevelOrgName" ></two-level-org>
                      </FormItem>
                    </i-col>
                    <i-col span="8">
                      <FormItem label="所属公司：">
                        <company-select v-model="formInline.companyName"></company-select>
                      </FormItem>
                    </i-col>
                    <i-col span="8">
                        <div style="float: right;">
                            <Button class="ivu-btn-query"  icon="md-search"  @click="query">查询</Button>
                            <Button class="ivu-btn-reset" style="margin-left: 10px" @click="cancel">重置</Button>
                            <Button @click="switchQuery(true)" style="margin-left: 5px" class="ivu-btn-switch2" type="text" >展开<Icon type="ios-arrow-down"/></Button>
                        </div>
                    </i-col>
                </Row>
            </div>
        </Form>
        <Row type="flex" justify="start" class="query-form">
            <i-col>
                <Button icon="md-add" class="ivu-btn-add" @click="addInfo">新增</Button>
                <Button type="primary" class="ivu-btn-add"  icon="md-cloud-download"  @click="exportForm" :loading="isSpin">导出</Button>
            </i-col>
        </Row>
        <Table ref='table' style="margin-top: 10px" :loading="loading" border :columns="columns" no-data-text="没有查询到相关数据！" @on-sort-change="querySort"
               :data="infos" width="100%" :height="tableHeight" highlight-row stripe size="small"></Table>
        <Row type="flex" justify="end" >
            <i-col>
                <Page :total="pagedata.total" :current="pagedata.currentPage" :page-size="pagedata.pageSize"
                      @on-page-size-change="pageSizeChange" @on-change="pageChange" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
            </i-col>
        </Row>
        <Modal v-model="modal1" width="1300" :mask-closable="false" :title="'人员行为安全观察记录' + titleName">
            <div :style="{height: divHeight, overflowY: 'auto', overflowX: 'hidden'}">
                <Form ref="formCustom" :model="formData" :rules="ruleCustom" label-position="top">
                    <Row :gutter="16">
                        <i-col span="6">
                            <FormItem label="观察日期：" prop="observationDate">
                                <DatePicker v-model="formData.observationDate"  style="width: 100%" format="yyyy-MM-dd" placeholder="请选择观察日期"></DatePicker>
                            </FormItem>
                        </i-col>
                        <i-col span="6">
                            <FormItem label="观察人员：" prop="observationUserName">
                                <userDom ref="userDom" :ifUser=true  :singleChoice=true @setData = "setUserInfo" :selectData='{name: formData.observationUserName}' :rootOrgId="rootOrgId"></userDom>
                            </FormItem>
                        </i-col>
                        <i-col span="6">
                            <FormItem label="观察部门：" prop="observationOrgId">
                                <orgDom ref="orgDom" @setOrgInfo="setOrgName" :orgInfo="{name: formData.orgName}"></orgDom>
                            </FormItem>
                        </i-col>
                        <i-col span="6">
                            <FormItem label="观察时长：" prop="observationDuration">
                                <TimePicker format="HH:mm" type="timerange" v-model="formData.duration" placement="bottom-end" placeholder="请选择观察时长" style="width: 100%"></TimePicker>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="6">
                            <FormItem label="被观察作业区域：" prop="observedWorkArea">
                                <Input v-model="formData.observedWorkArea" placeholder="请填写被观察作业区域"/>
                            </FormItem>
                        </i-col>
                        <i-col span="6">
                            <FormItem label="被观察作业：" prop="observedTask">
                                <Input v-model="formData.observedTask" placeholder="请填写被观察作业"/>
                            </FormItem>
                        </i-col>
                        <i-col span="6">
                            <FormItem label="被观察人员：" prop="observedUserName">
                                <Input v-model="formData.observedUserName" placeholder="请填写被观察人员"/>
                            </FormItem>
                        </i-col>
                        <i-col span="6">
                            <FormItem label="被观察人员类型：" prop="observedUserId">
                                <RadioGroup v-model="formData.observedUserId">
                                    <Radio label="内部员工"></Radio>
                                    <Radio label="相关方"></Radio>
                                </RadioGroup>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col span="24">
                            <Tabs ref="tabs">
                                <TabPane label="员工的反应" name="name1">
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="观察内容：" prop="employeeResponse">
                                                <CheckboxGroup v-model="formData.employeeResponse" size="small" @on-change="ifSafe1">
                                                    <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                    观察到人员异常反应：
                                                    <Checkbox v-for="(item, index) in employeeResponseList" :key="index" :label="item.codingCodeId" :disabled="disabled1" border>{{item.codingName}}</Checkbox>
                                                </CheckboxGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row style="margin-top: 8px">
                                        <i-col span="24">
                                            <FormItem label="观察沟通情况：" prop="observationCommunicationEmployeeResponse">
                                                <RadioGroup v-model="formData.observationCommunicationEmployeeResponse">
                                                    <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="整改建议：" prop="modifySuggestEmployeeResponse">
                                                <RadioGroup v-model="formData.modifySuggestEmployeeResponse">
                                                    <Radio v-for="item in proposalList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                </TabPane>
                                <TabPane label="员工的位置" name="name2">
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="观察内容：" prop="employeePosition">
                                                <CheckboxGroup v-model="formData.employeePosition" size="small" @on-change="ifSafe2">
                                                    <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                    可能：
                                                    <Checkbox v-for="(item, index) in employeePositionList" :key="index" :label="item.codingCodeId" :disabled="disabled2" border>{{item.codingName}}</Checkbox>
                                                </CheckboxGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row style="margin-top: 8px">
                                        <i-col span="24">
                                            <FormItem label="观察沟通情况：" prop="observationCommunicationEmployeePosition">
                                                <RadioGroup v-model="formData.observationCommunicationEmployeePosition">
                                                    <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="整改建议：" prop="modifySuggestEmployeePosition">
                                                <RadioGroup v-model="formData.modifySuggestEmployeePosition">
                                                    <Radio v-for="item in proposalList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                </TabPane>
                                <TabPane label="个人防护装备" name="name3">
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="观察内容：" prop="protectiveEquipment">
                                                <CheckboxGroup v-model="formData.protectiveEquipment" size="small" @on-change="ifSafe3">
                                                    <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                    未使用或未正确使用，或不完好：
                                                    <Checkbox v-for="(item, index) in protectiveEquipmentList" :key="index" :label="item.codingCodeId" :disabled="disabled3" border>{{item.codingName}}</Checkbox>
                                                </CheckboxGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row style="margin-top: 8px">
                                        <i-col span="24">
                                            <FormItem label="观察沟通情况：" prop="observationCommunicationProtectiveEquipment">
                                                <RadioGroup v-model="formData.observationCommunicationProtectiveEquipment">
                                                    <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="整改建议：" prop="modifySuggestProtectiveEquipment">
                                                <RadioGroup v-model="formData.modifySuggestProtectiveEquipment">
                                                    <Radio v-for="item in proposalList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                </TabPane>
                                <TabPane label="工具与设备" name="name4">
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="观察内容：" prop="toolsEquipment">
                                                <CheckboxGroup v-model="formData.toolsEquipment" size="small" @on-change="ifSafe4">
                                                    <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                    观察到的问题：
                                                    <Checkbox v-for="(item, index) in toolsEquipmentList" :key="index" :label="item.codingCodeId" :disabled="disabled4" border>{{item.codingName}}</Checkbox>
                                                </CheckboxGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row style="margin-top: 8px">
                                        <i-col span="24">
                                            <FormItem label="观察沟通情况：" prop="observationCommunicationToolsEquipment">
                                                <RadioGroup v-model="formData.observationCommunicationToolsEquipment">
                                                    <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="整改建议：" prop="modifySuggestToolsEquipment">
                                                <RadioGroup v-model="formData.modifySuggestToolsEquipment">
                                                    <Radio v-for="item in proposalList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                </TabPane>
                                <TabPane label="问询情况" name="name7">
                                  <Row>
                                    <i-col span="24">
                                      <FormItem label="观察内容：" prop="inquirySituation">
                                        <CheckboxGroup v-model="formData.inquirySituation" size="small" @on-change="ifSafe7">
                                          <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                          观察到的问题：
                                          <Checkbox v-for="(item, index) in inquirySituationList" :key="index" :label="item.codingCodeId" :disabled="disabled7" border>{{item.codingName}}</Checkbox>
                                        </CheckboxGroup>
                                      </FormItem>
                                    </i-col>
                                  </Row>
                                  <Row style="margin-top: 8px">
                                    <i-col span="24">
                                      <FormItem label="观察沟通情况：" prop="observationCommunicationInquirySituation">
                                        <RadioGroup v-model="formData.observationCommunicationInquirySituation">
                                          <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                        </RadioGroup>
                                      </FormItem>
                                    </i-col>
                                  </Row>
                                  <Row>
                                    <i-col span="24">
                                      <FormItem label="整改建议：" prop="modifySuggestInquirySituation">
                                        <RadioGroup v-model="formData.modifySuggestInquirySituation">
                                          <Radio v-for="item in proposalList" :label="item.label"></Radio>
                                        </RadioGroup>
                                      </FormItem>
                                    </i-col>
                                  </Row>
                                </TabPane>

                                <TabPane label="制度及规程" name="name5">
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="观察内容：" prop="program">
                                                <CheckboxGroup v-model="formData.program" size="small" @on-change="ifSafe5">
                                                    <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                    观察到的问题：
                                                    <Checkbox v-for="(item, index) in programList" :key="index" :label="item.codingCodeId" :disabled="disabled5" border>{{item.codingName}}</Checkbox>
                                                </CheckboxGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row style="margin-top: 8px">
                                        <i-col span="24">
                                            <FormItem label="观察沟通情况：" prop="observationCommunicationProgram">
                                                <RadioGroup v-model="formData.observationCommunicationProgram">
                                                    <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="整改建议：" prop="modifySuggestProgram">
                                                <RadioGroup v-model="formData.modifySuggestProgram">
                                                    <Radio v-for="item in proposalList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                </TabPane>
                                <TabPane label="人体工效学" name="name8">
                                  <Row>
                                    <i-col span="24">
                                      <FormItem label="观察内容：" prop="ergonomics">
                                        <CheckboxGroup v-model="formData.ergonomics" size="small" @on-change="ifSafe8">
                                          <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                          观察到的问题：
                                          <Checkbox v-for="(item, index) in ergonomicsList" :key="index" :label="item.codingCodeId" :disabled="disabled8" border>{{item.codingName}}</Checkbox>
                                        </CheckboxGroup>
                                      </FormItem>
                                    </i-col>
                                  </Row>
                                  <Row style="margin-top: 8px">
                                    <i-col span="24">
                                      <FormItem label="观察沟通情况：" prop="observationCommunicationErgonomics">
                                        <RadioGroup v-model="formData.observationCommunicationErgonomics">
                                          <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                        </RadioGroup>
                                      </FormItem>
                                    </i-col>
                                  </Row>
                                  <Row>
                                    <i-col span="24">
                                      <FormItem label="整改建议：" prop="modifySuggestErgonomics">
                                        <RadioGroup v-model="formData.modifySuggestErgonomics">
                                          <Radio v-for="item in proposalList" :label="item.label"></Radio>
                                        </RadioGroup>
                                      </FormItem>
                                    </i-col>
                                  </Row>
                                </TabPane>

                                <TabPane label="环境整洁" name="name6">
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="观察内容：" prop="cleanEnvironment">
                                                <CheckboxGroup v-model="formData.cleanEnvironment" size="small" @on-change="ifSafe6">
                                                    <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                    观察到的问题：
                                                    <Checkbox v-for="(item, index) in cleanEnvironmentList" :key="index" :label="item.codingCodeId" :disabled="disabled6" border>{{item.codingName}}</Checkbox>
                                                </CheckboxGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row style="margin-top: 8px">
                                        <i-col span="24">
                                            <FormItem label="观察沟通情况：" prop="observationCommunicationCleanEnvironment">
                                                <RadioGroup v-model="formData.observationCommunicationCleanEnvironment">
                                                    <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                    <Row>
                                        <i-col span="24">
                                            <FormItem label="整改建议：" prop="modifySuggestCleanEnvironment">
                                                <RadioGroup v-model="formData.modifySuggestCleanEnvironment">
                                                    <Radio v-for="item in proposalList" :label="item.label"></Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </i-col>
                                    </Row>
                                </TabPane>
                            </Tabs>
                        </i-col>
                    </Row>
                    <Divider />
                    <Row :gutter="16">
                        <i-col span="24">
                            <FormItem label="观察及询问作业人员结果：" prop="monQueryResult">
                                <Input v-model="formData.monQueryResult"  type="textarea" placeholder="请输入观察及询问作业人员结果" />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="24">
                            <FormItem label="与操作人员交流安全注意事项：" prop="staffCommuniSafetyIssue">
                                <Input v-model="formData.staffCommuniSafetyIssue"  type="textarea" placeholder="请输入与操作人员交流安全注意事项" />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                        <i-col span="24">
                            <FormItem label="综合评价：" prop="comprehensiveEvaluation">
                                <Input v-model="formData.comprehensiveEvaluation"  type="textarea" placeholder="请输入综合评价" />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row :gutter="16">
                      <i-col span="24">
                        <FormItem label="存在问题根源：">
                          <CheckboxGroup v-model="formData.problemOriginArray" size="small">
                            <Checkbox v-for="(item, index) in problemOriginList" :key="index" :label="item.codingCodeId" border>{{item.codingName}}</Checkbox>
                          </CheckboxGroup>

                        </FormItem>
                      </i-col>
                    </Row>
                    <Row :gutter="16">
                      <i-col span="24">
                        <FormItem label="改进建议和措施：">
                          <CheckboxGroup v-model="formData.proposalMeasuresArray" size="small">
                            <Checkbox v-for="(item, index) in proposalMeasuresList" :key="index" :label="item.codingCodeId" border>{{item.codingName}}</Checkbox>
                          </CheckboxGroup>
                        </FormItem>
                      </i-col>
                    </Row>
                </Form>
            </div>
            <div slot="footer">
                <Button @click="saveInfo" class="ivu-btn-save" :loading="buttonLoading">确定</Button>
                <Button @click="modal1 = false" class="ivu-btn-cancel" >取消</Button>
            </div>
        </Modal>

        <Modal v-model="modal2" width="1300" :mask-closable="false" title="人员行为安全观察记录详情">
            <div :style="{height: divHeight, overflowY: 'auto', overflowX: 'hidden'}">
                <Row class="modal-view-detail">
                    <Form :model="formData" :label-width="120">
                        <Row  :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col  span="6">
                                <FormItem label="观察日期：">
                                    {{this.formatDate(new Date(this.formData.observationDate), 'yyyy-MM-dd')}}
                                </FormItem>
                            </i-col>
                            <i-col  span="6">
                                <FormItem label="观察部门：">
                                    {{formData.orgName}}
                                </FormItem>
                            </i-col>
                            <i-col  span="6">
                                <FormItem label="观察人员：">
                                    {{formData.observationUserName}}
                                </FormItem>
                            </i-col>
                            <i-col  span="6">
                                <FormItem label="观察人员：">
                                    {{formData.observationDuration}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row  :gutter="16" type="flex" justify="space-around" class="code-row-bg">
                            <i-col span="6">
                                <FormItem label="被观察作业区域：">
                                    {{formData.observedWorkArea}}
                                </FormItem>
                            </i-col>
                            <i-col span="6">
                                <FormItem label="被观察作业：">
                                    {{formData.observedTask}}
                                </FormItem>
                            </i-col>
                            <i-col span="6">
                                <FormItem label="被观察人员：" prop="observedUserName">
                                    {{formData.observedUserName}}
                                </FormItem>
                            </i-col>
                            <i-col span="6">
                                <FormItem label="被观察人员类型：" prop="observedUserId">
                                    {{formData.observedUserId}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row>
                            <i-col span="24">
                                <Tabs ref="tabs2">
                                    <TabPane label="员工的反应" name="name1">
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="观察内容：" prop="employeeResponse">
                                                    <CheckboxGroup v-model="formData.employeeResponse" size="small" @on-change="ifSafe1">
                                                        <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                        观察到人员异常反应：
                                                        <Checkbox v-for="(item, index) in employeeResponseList" :key="index" :label="item.codingCodeId" :disabled="disabled1" border>{{item.codingName}}</Checkbox>
                                                    </CheckboxGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row style="margin-top: 8px">
                                            <i-col span="24">
                                                <FormItem label="观察沟通情况：" prop="observationCommunicationEmployeeResponse">
                                                    <RadioGroup v-model="formData.observationCommunicationEmployeeResponse">
                                                        <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="整改建议：" prop="modifySuggestEmployeeResponse">
                                                    <RadioGroup v-model="formData.modifySuggestEmployeeResponse">
                                                        <Radio v-for="item in proposalList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                    </TabPane>
                                    <TabPane label="员工的位置" name="name2">
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="观察内容：" prop="employeePosition">
                                                    <CheckboxGroup v-model="formData.employeePosition" size="small" @on-change="ifSafe2">
                                                        <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                        可能：
                                                        <Checkbox v-for="(item, index) in employeePositionList" :key="index" :label="item.codingCodeId" :disabled="disabled2" border>{{item.codingName}}</Checkbox>
                                                    </CheckboxGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row style="margin-top: 8px">
                                            <i-col span="24">
                                                <FormItem label="观察沟通情况：" prop="observationCommunicationEmployeePosition">
                                                    <RadioGroup v-model="formData.observationCommunicationEmployeePosition">
                                                        <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="整改建议：" prop="modifySuggestEmployeePosition">
                                                    <RadioGroup v-model="formData.modifySuggestEmployeePosition">
                                                        <Radio v-for="item in proposalList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                    </TabPane>
                                    <TabPane label="个人防护装备" name="name3">
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="观察内容：" prop="protectiveEquipment">
                                                    <CheckboxGroup v-model="formData.protectiveEquipment" size="small" @on-change="ifSafe3">
                                                        <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                        未使用或未正确使用，或不完好：
                                                        <Checkbox v-for="(item, index) in protectiveEquipmentList" :key="index" :label="item.codingCodeId" :disabled="disabled3" border>{{item.codingName}}</Checkbox>
                                                    </CheckboxGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row style="margin-top: 8px">
                                            <i-col span="24">
                                                <FormItem label="观察沟通情况：" prop="observationCommunicationProtectiveEquipment">
                                                    <RadioGroup v-model="formData.observationCommunicationProtectiveEquipment">
                                                        <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="整改建议：" prop="modifySuggestProtectiveEquipment">
                                                    <RadioGroup v-model="formData.modifySuggestProtectiveEquipment">
                                                        <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                    </TabPane>
                                    <TabPane label="工具与设备" name="name4">
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="观察内容：" prop="toolsEquipment">
                                                    <CheckboxGroup v-model="formData.toolsEquipment" size="small" @on-change="ifSafe4">
                                                        <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                        观察到的问题：
                                                        <Checkbox v-for="(item, index) in toolsEquipmentList" :key="index" :label="item.codingCodeId" :disabled="disabled4" border>{{item.codingName}}</Checkbox>
                                                    </CheckboxGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row style="margin-top: 8px">
                                            <i-col span="24">
                                                <FormItem label="观察沟通情况：" prop="observationCommunicationToolsEquipment">
                                                    <RadioGroup v-model="formData.observationCommunicationToolsEquipment">
                                                        <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="整改建议：" prop="modifySuggestToolsEquipment">
                                                    <RadioGroup v-model="formData.modifySuggestToolsEquipment">
                                                        <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                    </TabPane>
                                    <TabPane label="程序" name="name5">
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="观察内容：" prop="program">
                                                    <CheckboxGroup v-model="formData.program" size="small" @on-change="ifSafe5">
                                                        <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                        观察到的问题：
                                                        <Checkbox v-for="(item, index) in programList" :key="index" :label="item.codingCodeId" :disabled="disabled5" border>{{item.codingName}}</Checkbox>
                                                    </CheckboxGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row style="margin-top: 8px">
                                            <i-col span="24">
                                                <FormItem label="观察沟通情况：" prop="observationCommunicationProgram">
                                                    <RadioGroup v-model="formData.observationCommunicationProgram">
                                                        <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="整改建议：" prop="modifySuggestProgram">
                                                    <RadioGroup v-model="formData.modifySuggestProgram">
                                                        <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                    </TabPane>
                                    <TabPane label="环境整洁" name="name6">
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="观察内容：" prop="cleanEnvironment">
                                                    <CheckboxGroup v-model="formData.cleanEnvironment" size="small" @on-change="ifSafe6">
                                                        <Checkbox label="safe" border>全部安全</Checkbox><br/>
                                                        观察到的问题：
                                                        <Checkbox v-for="(item, index) in cleanEnvironmentList" :key="index" :label="item.codingCodeId" :disabled="disabled6" border>{{item.codingName}}</Checkbox>
                                                    </CheckboxGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row style="margin-top: 8px">
                                            <i-col span="24">
                                                <FormItem label="观察沟通情况：" prop="observationCommunicationCleanEnvironment">
                                                    <RadioGroup v-model="formData.observationCommunicationCleanEnvironment">
                                                        <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                        <Row>
                                            <i-col span="24">
                                                <FormItem label="整改建议：" prop="modifySuggestCleanEnvironment">
                                                    <RadioGroup v-model="formData.modifySuggestCleanEnvironment">
                                                        <Radio v-for="item in scoreList" :label="item.label"></Radio>
                                                    </RadioGroup>
                                                </FormItem>
                                            </i-col>
                                        </Row>
                                    </TabPane>
                                </Tabs>
                            </i-col>
                        </Row>
                        <Divider />
                        <Row :gutter="16">
                            <i-col span="24">
                                <FormItem label="观察及询问作业人员结果：">
                                    {{formData.monQueryResult}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16">
                            <i-col span="24">
                                <FormItem label="与操作人员交流安全注意事项：">
                                    {{formData.staffCommuniSafetyIssue}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16">
                            <i-col span="24">
                                <FormItem label="综合评价：" >
                                    {{formData.comprehensiveEvaluation}}
                                </FormItem>
                            </i-col>
                        </Row>
                        <Row :gutter="16">
                          <i-col span="24">
                            <FormItem label="存在问题根源：">
                              <CheckboxGroup v-model="formData.problemOriginArray" size="small">
                                <Checkbox v-for="(item, index) in problemOriginList" :key="index" :label="item.codingCodeId" border>{{item.codingName}}</Checkbox>
                              </CheckboxGroup>

                            </FormItem>
                          </i-col>
                        </Row>
                        <Row :gutter="16">
                          <i-col span="24">
                            <FormItem label="改进建议和措施：">
                              <CheckboxGroup v-model="formData.proposalMeasuresArray" size="small">
                                <Checkbox v-for="(item, index) in proposalMeasuresList" :key="index" :label="item.codingCodeId" border>{{item.codingName}}</Checkbox>
                              </CheckboxGroup>
                            </FormItem>
                          </i-col>
                        </Row>
                    </Form>
                </Row>
            </div>
            <div slot="footer">
                <Button @click="saveInfo" class="ivu-btn-save" :loading="buttonLoading">确定</Button>
                <Button @click="modal2 = false" class="ivu-btn-cancel" >取消</Button>
            </div>
        </Modal>
    </div>
</template>

<script>

    import {sessionStorage} from '@/common/cacheUtils.js';
    import {Api} from '../../../api'
    import orgDom from "@/components/input-org.vue";
    import userDom from "@/components/input-user.vue";

    export default {
        name: "observationRecordList",
        components:{
            orgDom,
            userDom
        },
        data(){
            return{
                isSpin: false,
                switchFlag: false,
                titleName: '',
                modal1: false,
                modal2: false,
                buttonLoading: false,
                formInline: {
                    se_date: []
                },
                formData: {},
                isUpdate: false,
                ruleCustom: {
                    observationDate: [
                        {
                            type: 'date',
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    observationOrgId: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change',
                            validator: (rule, value, callback) => {
                                if (this.formData.observationOrgId == undefined || this.formData.observationOrgId == '') {
                                    callback(' ');
                                } else {
                                    callback()
                                }
                            },
                        }
                    ],
                    observationUserName: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change',
                            validator: (rule, value, callback) => {
                                if (this.formData.observationUserName == undefined || this.formData.observationUserName == '') {
                                    callback(' ');
                                } else {
                                    callback();
                                }
                            },
                        }
                    ],
                    observedWorkArea: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    observedTask: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    observedUserId: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    observedUserName: [
                        {
                            required: true,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    observationCommunicationEmployeeResponse: [
                        {
                            required: true,
                            message: '请选择观察沟通情况',
                            trigger: 'blur,change'
                        }
                    ],
                    observationCommunicationEmployeePosition: [
                        {
                            required: true,
                            message: '请选择观察沟通情况',
                            trigger: 'blur,change'
                        }
                    ],
                    observationCommunicationProtectiveEquipment: [
                        {
                            required: true,
                            message: '请选择观察沟通情况',
                            trigger: 'blur,change'
                        }
                    ],
                    observationCommunicationToolsEquipment: [
                        {
                            required: true,
                            message: '请选择观察沟通情况',
                            trigger: 'blur,change'
                        }
                    ],
                    observationCommunicationProgram: [
                        {
                            required: true,
                            message: '请选择观察沟通情况',
                            trigger: 'blur,change'
                        }
                    ],
                    observationCommunicationInquirySituation: [
                        {
                            required: true,
                            message: '请选择观察沟通情况',
                            trigger: 'blur,change'
                        }
                    ],
                    observationCommunicationCleanEnvironment: [
                      {
                        required: true,
                        message: '请选择观察沟通情况',
                        trigger: 'blur,change'
                      }
                    ],
                    observationCommunicationErgonomics: [
                      {
                        required: true,
                        message: '请选择观察沟通情况',
                        trigger: 'blur,change'
                      }
                    ],
                    modifySuggestEmployeeResponse: [
                        {
                            required: false,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    modifySuggestEmployeePosition: [
                        {
                            required: false,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    modifySuggestProtectiveEquipment: [
                        {
                            required: false,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    modifySuggestToolsEquipment: [
                        {
                            required: false,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    modifySuggestProgram: [
                        {
                            required: false,
                            message: '  ',
                            trigger: 'blur,change'
                        }
                    ],
                    modifySuggestCleanEnvironment: [
                        {
                            required: false,
                            message: '请选择观察沟通情况',
                            trigger: 'blur,change'
                        }
                    ],
                    // observationDuration: [
                    //     { required: true, type: 'array', min: 1, message: '请选择填写时长', trigger: 'blur,change' },
                    // ],
                    employeeResponse: [
                        {
                            required: true,
                            message: '请选择观察内容',
                            trigger: 'blur,change',
                            type: 'array',
                            min: 1
                        }
                    ],
                    employeePosition: [
                        {
                            required: true,
                            message: '请选择观察内容！',
                            trigger: 'blur,change',
                            type: 'array',
                            min: 1
                        }
                    ],
                    protectiveEquipment: [
                        {
                            required: true,
                            message: '请选择观察内容！',
                            trigger: 'blur,change',
                            type: 'array',
                            min: 1
                        }
                    ],
                    toolsEquipment: [
                        {
                            required: true,
                            message: '请选择观察内容！',
                            trigger: 'blur,change',
                            type: 'array',
                            min: 1
                        }
                    ],
                    program: [
                        {
                            required: true,
                            message: '请选择观察内容！',
                            trigger: 'blur,change',
                            type: 'array',
                            min: 1
                        }
                    ],
                    cleanEnvironment: [
                        {
                            required: true,
                            message: '请选择观察内容！',
                            trigger: 'blur,change',
                            type: 'array',
                            min: 1
                        }
                    ],
                    ergonomics: [
                        {
                          required: true,
                          message: '请选择观察内容！',
                          trigger: 'blur,change',
                          type: 'array',
                          min: 1
                        }
                    ],
                    inquirySituation: [
                        {
                          required: true,
                          message: '请选择观察内容！',
                          trigger: 'blur,change',
                          type: 'array',
                          min: 1
                        }
                    ],
                },
                loading: false,
                tabName: 'name1',
                columns: [
                    {
                        title: '序号',
                        width: 80,
                        align: 'center',
                        fixed: 'left',
                        render: this.indexColumnsRender
                    },
                    {
                        title: '观察日期',
                        align: 'center',
                        key: 'observationDate',
                        minWidth: 120,
                        sortable: 'custom',
                        render:(h,params)=>{
                            return h('div',[
                                h('span', params.row.observationDate!= null ?this.formatDate(new Date(params.row.observationDate), 'yyyy-MM-dd'): '--')
                            ]);
                        }
                    },
                    {
                        title: '所属二级集团',
                        align: 'center',
                        key: 'twolevelOrgName',
                        minWidth: 180,
                        render:(h,params)=>{

                            return h('div',[
                                h('span',params.row.twolevelOrgName || '--')
                            ]);
                        }
                    },
                    {
                        title: '所属公司',
                        align: 'center',
                        key: 'companyName',
                        minWidth: 180,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.companyName? params.row.companyName: params.row.orgName || '--')
                            ]);
                        }
                    },
                    {
                        title: '观察部门',
                        align: 'center',
                        key: 'orgName',
                        minWidth: 180,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.orgName || '--')
                            ]);
                        }
                    },
                    {
                        title: '观察人员',
                        align: 'center',
                        key: 'observationUserName',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.observationUserName || '--')
                            ]);
                        }
                    },
                    {
                        title: '观察时长',
                        align: 'center',
                        key: 'observationDuration',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.observationDuration || '--')
                            ]);
                        }
                    },
                    {
                        title: '被观察作业区域',
                        align: 'center',
                        key: 'observedWorkArea',
                        minWidth: 150,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.observedWorkArea || '--')
                            ]);
                        }
                    },
                    {
                        title: '被观察作业',
                        align: 'center',
                        key: 'observedTask',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.observedTask || '--')
                            ]);
                        }
                    },
                    {
                        title: '被观察人员',
                        align: 'center',
                        key: 'observedUserName',
                        minWidth: 120,
                        render:(h,params)=>{
                            return h('div',[
                                h('span',params.row.observedUserName || '--')
                            ]);
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        key: 'view',
                        fixed: 'right',
                        minWidth: 250,
                        render: (h, params) => {
                            return h('div', [
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px'
                                    },
                                    on: {
                                        click: () => {
                                            this.updateRow(params.row);
                                            this.modal2 = true;
                                        }
                                    }
                                }, '详情'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.status == "1" || params.row.status == "2" || params.row.status == "3"? '#d0d0d0' : '',
                                        pointerEvents: params.row.status == "1" || params.row.status == "2" || params.row.status == "3"? 'none' : ''
                                    },
                                    on: {
                                        click: () => {
                                            this.titleName = "修改";
                                            this.isUpdate = true;
                                            this.updateRow(params.row);
                                            this.modal1 = true;
                                        }
                                    }
                                }, '修改'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: 'red',
                                    },
                                    on: {
                                        click: () => {
                                            this.deleteRow(params.row);
                                        }
                                    }
                                }, '删除'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                    },
                                    on: {
                                        click: () => {
                                            this.export(params.row)
                                        }
                                    }
                                }, '下载观察表')
                            ]);
                        }
                    }

                ],
                infos: [],
                tableHeight: '',
                pagedata: {
                    total: 0,
                    pageSize: 10,
                    currentPage: 1
                },
                pageSizeArray: [10, 20, 50],
                scoreList: [
                    {
                        label: '好'
                    },
                    {
                        label: '良好'
                    },
                    {
                        label: '一般'
                    },
                    {
                        label: '差'
                    },
                ],
                proposalList: [
                    {
                        label: '奖励'
                    },
                    {
                        label: '培训'
                    },
                    {
                        label: '宣传'
                    },
                ],
                employeeResponseList: [],
                employeePositionList: [],
                protectiveEquipmentList: [],
                toolsEquipmentList: [],
                programList: [],
                cleanEnvironmentList: [],
                inquirySituationList: [],
                ergonomicsList: [],
                problemOriginList: [],
                proposalMeasuresList: [],
                disabled1: false,
                disabled2: false,
                disabled3: false,
                disabled4: false,
                disabled5: false,
                disabled6: false,
                disabled7: false,
                disabled8: false,
                rootOrgId: '',
                userInfo: sessionStorage('userId').getObject('userId'),
                divHeight: ''
            }
        },
        mounted(){
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
            this.divHeight = window.innerHeight - 150 +'px';
            this.query();
            this.selectCodingSort();
        },
        watch: {
            "modal1":function(qw,er){
                if(!qw){
                    this.formData = {};
                    this.$refs.tabs.activeKey = 'name1'
                    this.$refs.userDom.resetCurrentUser();
                    this.$refs.orgDom.resetCurrentOrg();
                    this.disabled1 = false;
                    this.disabled2 = false;
                    this.disabled3 = false;
                    this.disabled4 = false;
                    this.disabled5 = false;
                    this.disabled6 =  false;
                    this.disabled7 = false;
                    this.disabled8 =  false;
                }
            },
            "modal2":function(qw,er){
                if(!qw){
                    this.formData = {};
                    this.$refs.tabs2.activeKey = 'name1'
                }
            },
        },
        methods: {
            exportForm(){
                this.isSpin = true;
                let data = {
                    observationOrgId: this.userInfo.companyId,
                };
                if(this.formInline.se_date.length!=0){
                    this.formInline.startDate = this.formatDate(this.formInline.se_date[0], 'yyyy-MM-dd');
                    this.formInline.endDate = this.formatDate(this.formInline.se_date[1], 'yyyy-MM-dd');
                }
                data = Object.assign(data,JSON.parse(JSON.stringify(this.formInline)));
                this.$http.get(Api.observationRecord + '/list/export', {
                    params: data,
                    responseType: 'blob' //告诉服务器我们需要的响应格式
                }).then((res) => {
                    const aLink = document.createElement("a");
                    let blob = new Blob([res.data], {
                        type: res.bodyBlob.type //将会被放入到blob中的数组内容的MIME类型
                    });
                    aLink.href = URL.createObjectURL(blob)
                    aLink.download = "人员行为观察(" + this.formatDate(new Date(), "yyyy-MM-dd") + ").xlsx" //标题
                    aLink.click()
                    document.body.appendChild(aLink)
                    this.isSpin = false
                }).catch(e => {
                    this.$Message.error("导出异常");
                    this.isSpin = false;
                })
            },
            query(){
                this.loading = true;
                let data = {
                    startPage: this.pagedata.currentPage,
                    pageSize: this.pagedata.pageSize,
                    observationOrgId: this.userInfo.companyId,
                };
                if(this.formInline.se_date.length!=0){
                    this.formInline.startDate = this.formatDate(this.formInline.se_date[0], 'yyyy-MM-dd');
                    this.formInline.endDate = this.formatDate(this.formInline.se_date[1], 'yyyy-MM-dd');
                }
                data = Object.assign(data,JSON.parse(JSON.stringify(this.formInline)));
                this.$http.get(Api.observationRecord, {
                    params: data
                }).then(function(res){
                    this.infos = res.data.data.data;
                    this.pagedata.total = res.data.data.totalSize;
                    this.loading = false;
                }, function(res){
                    this.$Message.error('请求失败');
                });
            },
            cancel(){
                this.formInline = {
                    se_date: []
                };
                this.query();
            },
            addInfo() {
                this.titleName = '新增';
                this.isUpdate = false;
                this.rootOrgId = this.userInfo.companyId;
                this.modal1 = true;
            },
            updateRow(row){
                this.$set(this.ruleCustom.modifySuggestCleanEnvironment[0], 'required', false);
                this.isUpdate = true;
                this.formData = JSON.parse(JSON.stringify(row));
                this.$set(this.formData, 'employeeResponse', this.formData.observationContentEmployeeResponse.split(','));
                this.$set(this.formData, 'employeePosition', this.formData.observationContentEmployeePosition.split(','));
                this.$set(this.formData, 'protectiveEquipment', this.formData.observationContentProtectiveEquipment.split(','));
                this.$set(this.formData, 'toolsEquipment', this.formData.observationContentToolsEquipment.split(','));
                this.$set(this.formData, 'program', this.formData.observationContentProgram.split(','));
                this.$set(this.formData, 'cleanEnvironment', this.formData.observationContentCleanEnvironment.split(','));
                this.$set(this.formData, 'duration', this.formData.observationDuration.split(','));
                if(this.formData.observationContentInquirySituation){
                  this.$set(this.formData, 'inquirySituation', this.formData.observationContentInquirySituation.split(','));
                }
                if(this.formData.observationContentErgonomics){
                  this.$set(this.formData, 'ergonomics', this.formData.observationContentErgonomics.split(','));
                }
                if(this.formData.problemOrigin){
                  this.$set(this.formData, 'problemOriginArray', this.formData.problemOrigin.split(','));
                }
                if(this.formData.proposalMeasures){
                  this.$set(this.formData, 'proposalMeasuresArray', this.formData.proposalMeasures.split(','));
                }


                setTimeout(() => {
                    this.$refs.orgDom.setCurrentOrg();
                    this.$refs.userDom.setCurrentInfo();
                }, 300);
            },
            deleteRow(row){
                this.$Modal.confirm({
                    title: '数据删除',
                    content: '<p>确定删除该条信息</p>',
                    okText: '确认',
                    onOk: () => {
                        this.$http.delete(Api.observationRecord, {params:{
                                id: row.id,
                                updateUserId: this.userInfo.userId,
                                updateDate: new Date()
                            }}).then((res) => {
                            this.$Message.success({content:'删除成功',duration: 4});
                            this.query();
                        })
                    },
                    cancelText: '取消'
                });
            },
            export(row){
                this.isSpin = true;
                this.$http.get(Api.observationRecord + '/export',{
                    params:{
                        id: row.id,
                    },
                    responseType: 'arraybuffer'
                }).then((res) => {
                    const aLink = document.createElement("a");
                    let blob = new Blob([res.data], {
                        type: "application/msword"
                    })
                    aLink.href = URL.createObjectURL(blob);
                    aLink.download = "人员行为安全观察记录.docx" //标题
                    aLink.click();
                    document.body.appendChild(aLink);
                    this.isSpin = false;
                }).catch(e => {
                    this.$Message.error("数据获取失败");
                    this.isSpin = false;
                })
            },
            pageSizeChange(pageSize){
                this.pagedata.pageSize = pageSize;
                this.query();
            },
            pageChange(pageNum){
                this.pagedata.currentPage = pageNum;
                this.query();
            },
            indexColumnsRender(h, params){
                return h('span', params.index + (this.pagedata.currentPage - 1) * this.pagedata.pageSize + 1);
            },
            saveInfo(){
                this.$refs['formCustom'].validate((valid) => {
                    if(valid){
                        this.$set(this.formData, 'observationContentEmployeeResponse', this.formData.employeeResponse.toString());
                        this.$set(this.formData, 'observationContentEmployeePosition', this.formData.employeePosition.toString());
                        this.$set(this.formData, 'observationContentProtectiveEquipment', this.formData.protectiveEquipment.toString());
                        this.$set(this.formData, 'observationContentToolsEquipment', this.formData.toolsEquipment.toString());
                        this.$set(this.formData, 'observationContentProgram', this.formData.program.toString());
                        this.$set(this.formData, 'observationContentCleanEnvironment', this.formData.cleanEnvironment.toString());
                        this.$set(this.formData, 'observationDuration', this.formData.duration.toString());
                        this.$set(this.formData, 'observationContentErgonomics', this.formData.ergonomics.toString());
                        this.$set(this.formData, 'observationContentInquirySituation', this.formData.inquirySituation.toString());

                      if(this.formData.problemOrigin){
                        this.$set(this.formData, 'problemOrigin', this.formData.problemOriginArray.toString());
                      }
                      if(this.formData.proposalMeasures){
                        this.$set(this.formData, 'proposalMeasures', this.formData.proposalMeasuresArray.toString());
                      }

                      this.buttonLoading = true;
                        if(this.isUpdate) {
                            this.$http.put(Api.observationRecord,this.formData).then(function(response){
                                this.buttonLoading = false;
                                this.modal1 = false;
                                this.query();
                                this.$Message.success({  content: '保存成功', duration: 4 });
                            });
                        }else{
                            this.$http.post(Api.observationRecord,this.formData).then(function(response){
                                this.buttonLoading = false;
                                this.modal1 = false;
                                this.query();
                                this.$Message.success({  content: '保存成功', duration: 4 });
                            });
                        }
                    }else{
                        this.$Message.error({  content: '请检查必填项是否完整！', duration: 4 });
                    }
                });
            },
            setOrgName(data){
                this.formData.observationOrgId = data.orgId;
                // this.rootOrgId = data.orgId;
            },
            setUserInfo(data){
                this.formData.observationUserId = data.userId;
                this.formData.observationUserName = data.userName;
                this.$set(this.formData, 'orgName',  data.orgName)
                this.formData.observationOrgId = data.orgId;
                setTimeout(() => {
                    this.$refs.orgDom.setCurrentOrg();
                }, 300);
            },
            selectCodingSort(){
                this.$http.get(Api.queryCodeDetailBySortId + '/CR-00001', {params: {}}).then((res) => {
                    this.employeeResponseList = res.data.data;
                });
                this.$http.get(Api.queryCodeDetailBySortId + '/CR-00002', {params: {}}).then((res) => {
                    this.employeePositionList = res.data.data;
                });
                this.$http.get(Api.queryCodeDetailBySortId + '/CR-00003', {params: {}}).then((res) => {
                    this.protectiveEquipmentList = res.data.data;
                });
                this.$http.get(Api.queryCodeDetailBySortId + '/CR-00004', {params: {}}).then((res) => {
                    this.toolsEquipmentList = res.data.data;
                });
                this.$http.get(Api.queryCodeDetailBySortId + '/CR-00005', {params: {}}).then((res) => {
                    this.programList = res.data.data;
                });
                this.$http.get(Api.queryCodeDetailBySortId + '/CR-00006', {params: {}}).then((res) => {
                    this.cleanEnvironmentList = res.data.data;
                });
                this.$http.get(Api.queryCodeDetailBySortId + '/CR-00008', {params: {}}).then((res) => {
                  this.inquirySituationList = res.data.data;
                });
                this.$http.get(Api.queryCodeDetailBySortId + '/CR-00007', {params: {}}).then((res) => {
                  this.ergonomicsList = res.data.data;
                });
                this.$http.get(Api.queryCodeDetailBySortId + '/CR-00009', {params: {}}).then((res) => {
                  this.problemOriginList = res.data.data;
                });
                this.$http.get(Api.queryCodeDetailBySortId + '/CR-00010', {params: {}}).then((res) => {
                  this.proposalMeasuresList = res.data.data;
                });


            },
            setModifySuggest(){

            },
            ifSafe1(value){
                if(value.indexOf('safe') == 0){
                    this.disabled1 = true;
                }else{
                    this.disabled1 = false;
                }
            },
            ifSafe2(value){
                if(value.indexOf('safe') == 0){
                    this.disabled2 = true;
                }else{
                    this.disabled2 = false;
                }
            },
            ifSafe3(value){
                if(value.indexOf('safe') == 0){
                    this.disabled3 = true;
                }else{
                    this.disabled3 = false;
                }
            },
            ifSafe4(value){
                if(value.indexOf('safe') == 0){
                    this.disabled4 = true;
                }else{
                    this.disabled4 = false;
                }
            },
            ifSafe5(value){
                if(value.indexOf('safe') == 0){
                    this.disabled5 = true;
                }else{
                    this.disabled5 = false;
                }
            },
            ifSafe6(value){
                if(value.indexOf('safe') == 0){
                    this.disabled6 = true;
                }else{
                    this.disabled6 = false;
                }
            },
            ifSafe7(value){
              if(value.indexOf('safe') == 0){
                this.disabled7 = true;
              }else{
                this.disabled7 = false;
              }
            },
            ifSafe8(value){
              if(value.indexOf('safe') == 0){
                this.disabled8 = true;
              }else{
                this.disabled8 = false;
              }
            },
            formatDate(date, fmt) {
                if (typeof date == 'string') {
                    return date;
                }
                if (!fmt) fmt = "yyyy-MM-dd hh:mm:ss";
                if (!date || date == null) return null;
                let o = {
                    'M+': date.getMonth() + 1, // 月份
                    'd+': date.getDate(), // 日
                    'h+': date.getHours(), // 小时
                    'm+': date.getMinutes(), // 分
                    's+': date.getSeconds(), // 秒
                    'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
                    'S': date.getMilliseconds() // 毫秒
                }
                if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
                for (let k in o) {
                    if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
                }
                return fmt
            },
            switchQuery(flag){
                this.switchFlag = flag;
                if(this.switchFlag) {
                    this.tableHeight = this.tableHeight - 44;
                }else{
                    this.tableHeight = this.tableHeight + 44;
                }
            },
            querySort({column, key, order}){
              this.formInline.key = key;
              this.formInline.order = order;
              this.query();
            }
        }
    }
</script>

<style scoped>
    @import '../../../index.css';
    .demo-spin-icon-load{
        animation: ani-demo-spin 1s linear infinite;
    }
</style>
